package method

import (
	"database/sql"
	// "fmt"

	"gitlab.gybin.com/GYbin/structure"
)

func checkErr(err error) {
	if err != nil {
		panic(err)
	}
}

func PhotodDir(db *sql.DB, tableName string) {
	photoDir := structure.PhotoDir{
		Id:           0,
		DirName:      "root",
		DirAliasName: "root",
		ParentId:     0,
		FullDir:      "",
		Source:       "root",
	}
	createTablesStruct(photoDir, db, tableName)
	//初始化PhotodDir表中的数据
	stmt, err := db.Prepare("INSERT INTO photodir(dirname, diraliasname, parentid,source) values(?,?,?,?)")
	checkErr(err)
	res, err := stmt.Exec(photoDir.DirName, photoDir.DirAliasName, photoDir.ParentId, photoDir.Source)
	checkErr(err)
	_, err = res.LastInsertId()
	checkErr(err)
}
